import java.util.LinkedList;
import java.util.Queue;

public class Solution {
    class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        public TreeNode(int val) {
            this.val = val;
        }
    }
    public TreeNode Mirror (TreeNode pRoot) {
        if(pRoot==null){
            return  null;
        }
       TreeNode left=Mirror(pRoot.left);
        TreeNode right=Mirror(pRoot.right);
        pRoot.left=right;
        pRoot.right=left;
        return  pRoot;
}
    public static boolean HasSubtree1(TreeNode root1, TreeNode root2) {
            if(root1==null&&root2!=null){
                return false;
            }
            if(root2==null){
                return false;
            }
            if(root1==null&&root2==null){
                return true;
            }
            //判断是否是两棵相同的树
            if(HasSubtreeChild(root1,root2)){
                return true;
            }
            //判断root2是不是root1的左子树
            if(HasSubtreeChild(root1.left,root2)){
                return true;
            }
            //判断root2是不是root1的右子树
            if(HasSubtreeChild(root1.right,root2)){
                return true;
            }
            return false;
        }
        protected static boolean HasSubtreeChild(TreeNode r1, TreeNode r2) {
            if (r1 == null && r2 != null ||
                    r1 != null && r2 == null) {
                return false;
            }
            if (r1 == null && r2 == null) {
                return true;
            }
            if (r1.val != r2.val) {
                return false;
            }
            return HasSubtreeChild(r1.left, r2.left)
                    && HasSubtreeChild(r1.right, r2.right);
        }
    }
